#[macro_use] extern crate serde;

use std::collections::HashMap;
use std::io::prelude::*;
use std::net::TcpStream;
use serde_json::json;
const DINGDING_URL: &'static str = "https://oapi.dingtalk.com/robot/send?access_token=039d04c836073bcfbbd0d826e5eca1d5e4ba04c3b9c89fe7376d7f7c31c03fb0";

pub fn dingtalk_send_example() {
    let mut args: HashMap<String, String> = HashMap::new();
    args.insert(String::from("msgtype"), String::from("link"));
    args.insert(String::from("title"),String::from("AAAAA"));
    args.insert(String::from("text"),String::from("ABBBBBB"));
    args.insert(String::from("picUrl"), String::from("https://zj.v.api.aa1.cn/api/60s-old/"));

    let mut request = TcpStream::connect(DINGDING_URL).unwrap();
    request.write_all(json!(args).to_string().as_bytes()).unwrap();
    request.flush().unwrap();
}